package com.lx.test.dao;

import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import com.lx.test.entity.User;

import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

/**
 * Created by lxl on 2016/5/2.
 */
@Repository
@Transactional
public class UserDao {

    @PersistenceContext
    private EntityManager entityManager ;


    public void save(User user){

        entityManager.persist(user);


    }

    
    public List<User> getAllUser(){
    	
    	return entityManager.createNamedQuery("AllUser").getResultList() ;
    	
    	
    }
    
}
